<?php

namespace App\Enums;

enum TableStatus: string
{
    /**
     * 空闲
     */
    case Idle = "idle";

    /**
     * 使用中
     */
    case Used = "used";

    //内虚拟
    case InnerVirtual = 'inner_virtual';

    //外虚拟
    case OuterVirtual = 'outer_virtual';

    /**
     * 维护中
     */
    case Repair = "repair";

    public static function getOpenedStatus()
    {
        return [
            self::Used,
            self::InnerVirtual,
            self::OuterVirtual
        ];
    }

    public function isOpened()
    {
        if (in_array($this, self::getOpenedStatus())) {
            return true;
        }
        return false;
    }

    public function isVirtual()
    {
        if ($this == self::InnerVirtual || $this == self::OuterVirtual) {
            return true;
        }
        return false;
    }

    public function label()
    {
        return match ($this)
        {
            self::Idle => '空闲',
            self::Used => '已开台',
            self::Repair => '维护中',
            self::InnerVirtual => '内虚拟',
            self::OuterVirtual => '外虚拟',
        };
    }
}
